import Vue from 'vue'
import Router from 'vue-router'
/* Layout */
const _import = require('./_import_' + process.env.NODE_ENV)

Vue.use(Router)
let path = ''
// if (process.env.NODE_ENV !== 'development') {
//   path = '/qianduan'
// }
export const commonRoutes = [
	{ // 首页部分
		path: path + '',
		children: [
			{
				path: '',
				component: _import('index/index'),
				meta: { title: '首页', name: 'index' }
			}
		]
	},
	{
		path: path + '/index',
		component: _import('index/index'),
		meta: { title: '首页', name: 'index' }
	}
]

const router = new Router({
  mode: 'history',
  routes: commonRoutes
})

// var _hmt = window._hmt || []

router.beforeEach((to, from, next) => {
  if (to.meta.title) { // 如果设置标题，拦截后设置标题
    document.title = to.meta.title
  }

  // var _hmt = [];
  // (function() {
  //   var hm = document.createElement('script')
  //   hm.src = 'https://hm.baidu.com/hm.js?2f09dd62369eb852fe48bdb15d95358c'
  //   var s = document.getElementsByTagName('script')[0]
  //   s.parentNode.insertBefore(hm, s)
  // }
  // )()
  // _hmt.push(['_trackPageview', '' + to.fullPath])

  next()
})

export default router
